#ifndef QUERY_HANDLER_H
#define QUERY_HANDLER_H

#include <QtCore/QThread>
#include <QtSql/QSqlDatabase>

namespace dbmanager {

class DatabaseManagerPrivate;
class SqlQuery;

class QueryHandler : public QThread {
  Q_OBJECT
public:
  QueryHandler(int id, DatabaseManagerPrivate *parent);

  ~QueryHandler();

private slots:

  void threadStarted();

  void threadStoped();

  void execNextQuery();

private:

  void createDatabase();

  void destroyDatabase();

  bool checkAndOpenDb();

  void exec(SqlQuery *query);

  QSqlDatabase *database;

  DatabaseManagerPrivate *parent;

  QString db_name;
};

} // namespace dbmanager

#endif // QUERY_HANDLER_H
